package org.atovio.blog.mapper;

import org.apache.ibatis.annotations.*;
import org.atovio.blog.model.pojo.People;

import java.util.List;

/**
 * @author AtoVio, Winter Yuan
 */
public interface PeopleMapper {

    /**
     * 三表联查，根据id查询
     * @param id people_id
     * @param pageSize 分页大小
     * @return 人对象
     */
    @Select("""
            select id, name, age, provenance_id, sex, country, cv_id
            from people
            where id >= #{id}
            order by id desc
            limit #{pageSize}
            """)
    @Results(id = "AllColumnMap", value = {
            @Result(property = "cv", column = "cv_id",
                    one = @One(select = "org.atovio.blog.mapper.CvMapper.selectById")),
            @Result(property = "provenance", column = "provenance_id",
                    one = @One(select = "org.atovio.blog.mapper.ProvenanceMapper.selectById"))
            }
    )
    List<People> topShowIdBigger(Integer id, Integer pageSize);
}
